package erfgame.core.entity;

import java.util.Map;

import erfgame.core.world.World;

public class DelegatingEntityByTypeFactory implements EntityByTypeFactory {
	
	private Map<EntityType, EntityByTypeFactory> factories;
	
	public DelegatingEntityByTypeFactory( Map<EntityType, EntityByTypeFactory> factories ) {
		this.factories = factories;
	}
	
	public Entity createEntity(World world, EntityType type) {
		EntityByTypeFactory factory = factories.get( type );
		Entity result;
		if( factory != null ) {
			result = factory.createEntity(world, type);
		} else {
			result = null;
		}
		return result;
	}

}
